//
//  LeftTitleTableViewCell.m
//  兼职页面
//
//  Created by kuiyuan liang on 2021/5/23.
//

#import "LeftTitleTableViewCell.h"
#import "CommonUtil.h"

@interface LeftTitleTableViewCell ()
@property (strong, nonatomic) UIView * indexView;
@property (strong, nonatomic) UILabel * titleLabel;
@end

@implementation LeftTitleTableViewCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        self.backgroundColor = [UIColor whiteColor];
        [self addSubview:self.indexView];
        [self addSubview:self.titleLabel];
    }
    return self;
}

-(void)layoutSubviews{
    [super layoutSubviews];
    self.titleLabel.frame = self.bounds;
    self.indexView.height = self.height;
}

-(void)refreshData:(NSString *)data isSelect:(BOOL)isSelect{
    self.titleLabel.text = data;
    if (isSelect) {
        self.titleLabel.textColor = [UIColor redColor];
        self.indexView.hidden = false;
    }else{
        self.titleLabel.textColor = [UIColor blackColor];
        self.indexView.hidden = YES;
    }
}

#pragma mark - lazy

-(UIView *)indexView{
    if (!_indexView) {
        _indexView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, AD(3), 0)];
        _indexView.backgroundColor = RGB(255.0, 82.0, 109.0);
    }
    return _indexView;
}

-(UILabel *)titleLabel{
    if (!_titleLabel) {
        _titleLabel = [[UILabel alloc] init];

        _titleLabel.font = [UIFont systemFontOfSize:AD(15)];
        _titleLabel.textAlignment = NSTextAlignmentCenter;
    }
    return _titleLabel;
}

@end
